#include "supervisor.h"
#include "hw/board.h"

#if 0
void Supervisor::on_refhesh_timer(rl::message::RefreshTime &msg) {
  Parent::on_refhesh_timer(msg);
  auto dht = get_child<0>();
  dht->refresh();
}
#endif

void Supervisor::advance_start() {
  Parent::advance_start();
  auto dht = get_child<0>();
  auto uart = get_child<1>();
  send<rl::ctx::thread, message::RequestHT>(0, dht->get_id());
  send<rl::ctx::thread, message::LogStatic>(0, uart->get_id(),
                                            "starting supervisor...\r\n");
  blink_led();
}

void Supervisor::blink_led() {
    hw::Board::toggle_led();
    add_event<rl::ctx::thread>(100000, [](void* data){
        static_cast<Supervisor*>(data)->blink_led();
    }, this);
}
